import java.util.concurrent.Semaphore;

public class Demo32 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(4);
        semaphore.acquire();
        System.out.println("P 操作!");
        semaphore.acquire();
        System.out.println("P 操作!");
        semaphore.acquire();
        System.out.println("P 操作!");
        semaphore.acquire();
        System.out.println("P 操作!");
        // 最后一个阻塞等待
        semaphore.acquire();
        System.out.println("P 操作!");
        semaphore.release();
    }
}
